<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/WEB-INF/jsp/common/fadeout.jsp"></jsp:include>
<input type="hidden" name="subCustomerNo" value="${sub_customer_no}"/>
<div id="local_sub_order" class="easyui-layout" data-options='fit:true'> 
	<div id="sub_layout" class="easyui-layout" data-options="fit:true" style="width:600px;height:400px;">   
    	<div data-options="region:'center',title:'订单信息',split:'false'" >
    		<table id="sub_datagrid">
    		<div id="sub_deliver_tb">
    			<a href="javascript:void(0);" onclick="subDeliver()" class="easyui-linkbutton" data-options="iconCls:'icon-lorry_go',plain:true">发货</a>|
    		</div>
    		</table>
    	</div>
    </div>
</div>
<div id="address_content"></div> 
<script>
$(function(){
	$("#sub_datagrid").datagrid({    
	    url:'admin/deliver/detail.do?customer_no='+$("input[name='subCustomerNo']").val(), 
	    loadMsg:'数据加载中···',
	    fit:'true',
	    idField:'id',
	    pagination:true,
	    rownumbers:true,//行号  
	    checkOnSelect : true,
		selectOnCheck : true,
	    columns:[[
		{
			field : "id",
			hidden : true
		},     
	    {
			field:'customer_no',
			title:'客户编号',
			width:200,
			align:'center'
	    },    
	    {
	    	field:'order_no',
	    	title:'订单编号',
	    	width:200,
	    	align:'center'
	     },
	     {
	    	 field:'business_type',
	    	 title:'订单业务类型',
	    	 width:200,
	    	 align:'center'
	    },     
	    {
			field:'pro_no',
			title:'商品编码',
			width:220,
			align:'center',
	    },     
	    {
			field:'pro_name',
			title:'商品名称',
			width:160,
			align:'center',
	    },{
	    	field:'size',
	    	title:'尺寸',
	    	width:180,
	    	align:'center',
	        formatter: function(value,row,index){
	        	return row.length+"x"+row.width+"x"+row.height;
	    }},{
	    	 field:'weight',
	    	 title:'重量',
	    	 width:120,
	    	 align:'center'
	    },{
	    	 field:'pre_postage',
	    	 title:'预估邮费',
	    	 width:120,
	    	 align:'center',
	    	 formatter:function(value, row, index){
	    		 var a;
	    		 var b;
	    		 if(row['laborFee']==null){
	    			 a = 0;
	    		 }
	    		 if(row['postage']==null){
	    			 b = 0;
	    		 }
	    		 if(row['laborFee']==null && row['postage']==null ){
	    			 return "待定";
	    		 }else{
	    			 return row['laborFee']+row['postage'];
	    		 }
	    	 }
	    },{
	    	 field:'pro_number',
	    	 title:'数量',
	    	 width:120,
	    	 align:'center'
	    },
	     {
	    	 field:'warehouse',
	    	 title:'有效仓库',
	    	 width:140,
	    	 align:'center'
	    },{
	    	 field:'location',
	    	 title:'区位',
	    	 width:140,
	    	 align:'center'
	    },{
	    	 field:'loc_no',
	    	 title:'库位号',
	    	 width:140,
	    	 align:'center'
	    },{
	    	 field:'dis_address',
	    	 title:'发货地址',
	    	 width:90,
	    	 align:'center',
	    	 formatter: function(value,row,index){
	   	        	return "<a href='javascript:void(0)' onclick=\"showAddress('"+row['dis_address']+"')\">查看</a>";
	   	     }
	    },{
   	    	field:'create_tm',
   	    	title:'下单时间',
   	    	width:250,
   	    	align:'center',
   	        formatter: function(value,row,index){
   	        	return getTime(value);
   	        }
	     }
	    ]],
	    fitColumns:true,
	    toolbar:'#sub_deliver_tb'
	});  	
});
function showAddress(address){
	alert(address);
// 	$("#address_content").remove();
// 	$("#address_content").append(address);
// 	$('#address_content').window({    
// 	    width:600,    
// 	    height:400,    
// 	    modal:true   
// 	});  
}
function subDeliver(){
	$.ajax({
		url : "admin/deliver/deleverOrders.do?customerNo="+$("input[name='subCustomerNo']").val(),
		dataType : "json",
		success : function(data) {
			if (data && data.success) {
				if (data.msg && data.msg != "")
					//parent.$.messager.alert('提示', data.msg);
					alert(data.msg);
				else
					alert("提交失败！");
					//parent.$.messager.alert('提示', "提交失败");
				$("#deliver_dialog").dialog('close');
			} else {
				//parent.$.messager.alert('错误', data.msg);
				alert("提交失败！");
			}
}});
	$("#sub_datagrid").datagrid('reload');
}
</script>